package com.spring.boot.controller;

import com.spring.boot.pojo.JsonResult;
import com.spring.boot.pojo.UserP;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * 测试响应数据
 */
@RestController
public class ResponseController {
    /**
     * 响应字符串
     * @return
     */
    @RequestMapping("/hello")
    public JsonResult hello() {
        System.out.println("Hello World~");
        return JsonResult.success("Hello World~");
    }

    /**
     * 响应json
     * @return
     */
    @RequestMapping("/responseJson")
    public UserP responseJson() {
        UserP user=new UserP();
        user.setName("Hello");
        user.setAge(11);
        return user;
    }

    @RequestMapping("/responseList")
    public List<UserP> responseList() {
        List<UserP> userList=new ArrayList<>() ;
        UserP user=new UserP();
        user.setName("Hello");
        user.setAge(11);
        userList.add(user);
        UserP userWorld=new UserP();
        userWorld.setName("Hello");
        userWorld.setAge(11);
        userList.add(userWorld);
        return userList;
    }
}
